//
//  NYIntroduceView.m
//  NiuWaJiaoYu
//
//  Created by MinLison on 2018/1/6.
//  Copyright © 2018年 niuwaketang. All rights reserved.
//

#import "NYIntroduceView.h"

@interface NYIntroduceView ()

@property(nonatomic, strong) DTAttributedTextView *textView;
@property(nonatomic, strong) NYHtmlHelper *htmlHelper;

@end

@implementation NYIntroduceView

- (void)setupView
{
    [super setupView];
    [self addSubview:self.textView];
    [self setBackgroundColor:[UIColor whiteColor]];
    [self.textView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        if (@available(iOS 11.0,*))
        {
            make.bottom.equalTo(self.mas_safeAreaLayoutGuideBottom);
            make.top.equalTo(self.mas_safeAreaLayoutGuideTop);
            make.left.equalTo(self.mas_safeAreaLayoutGuideLeft).offset(15);
            make.right.equalTo(self.mas_safeAreaLayoutGuideRight).offset(-15);
        }
        else
        {
            make.bottom.equalTo(self.controller.mas_bottomLayoutGuideTop);
            make.top.equalTo(self.controller.mas_topLayoutGuideBottom);
            make.left.equalTo(self.mas_left).offset(15);
            make.right.equalTo(self.mas_right).offset(-15);
            //                        make.left.right.equalTo(self);
        }
    }];
}
- (void)setHtmlString:(NSString *)htmlString
{
    _htmlString = htmlString;
    self.textView.attributedString = [self.htmlHelper attributedStringForHtmlString:self.htmlString maxImageSize:CGSizeMake(__WGWidth(self.width), CGFLOAT_MAX) imgSizeCallBackBlock:^(CGSize imgSize) {
        
    }];
}
- (NYHtmlHelper *)htmlHelper
{
    if (_htmlHelper == nil) {
        _htmlHelper = [[NYHtmlHelper alloc] init];
    }
    return _htmlHelper;
}
- (DTAttributedTextView *)textView
{
    if (_textView == nil) {
        _textView = [[DTAttributedTextView alloc] init];
    }
    return _textView;
}

@end
